package io;

import java.io.*;
import java.util.Scanner;

public class FileCopy {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入需要复制的文件路径");
        String src = in.next();
        System.out.println("请输入传输后的文件路径");
        String dest = in.next();
        File srcFile = new File(src);
        if (!srcFile.exists()) {
            System.out.println("文件不存在");
            return;
        }
        if (srcFile.isDirectory()) {
            System.out.println("目录文件暂不支持复制");
            return;
        }
        File destFile = new File(dest);
        destFile.createNewFile();
        try (OutputStream outputStream = new FileOutputStream(destFile);
             InputStream inputStream = new FileInputStream(srcFile);) {

            byte[] bytes = new byte[1024];
            int n;
            while ((n = inputStream.read(bytes)) != -1) {
                outputStream.write(bytes, 0, n);
            }
        }


    }
}
